package com.lagou.impl;

import com.lagou.Player;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author mcl
 * @date 2021/12/29 13:59
 * @description
 */
public class LagouPlayer implements Player {

    private String userName;

    public LagouPlayer() {
    }

    public LagouPlayer(String userName) {
        this.userName = userName;
    }

    @Override
    public String getUsername() {
        return userName;
    }

    @Override
    public void write(String message) {
        System.out.println("Write message: ".concat(message).concat(" to User: ").concat(userName));
    }

    @Override
    public boolean isOffline() {
        System.out.println("Player: ".concat(userName).concat(" is offline."));
        return ThreadLocalRandom.current().nextBoolean();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
